package org.timeismoney.payment.dao.impl;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Property;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.timeismoney.payment.dao.SchoolYearDao;
import org.timeismoney.payment.model.SchoolYear;

public class SchoolYearDaoImpl extends GenericDaoImpl<SchoolYear, Integer> implements SchoolYearDao {

	public SchoolYearDaoImpl() {
		this.setClazz(SchoolYear.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<SchoolYear> getEntitys() {
		return (List<SchoolYear>) getHibernateTemplate().execute(new HibernateCallback() {
			
			public Object doInHibernate(Session session) throws HibernateException,
					SQLException {
				return session.createCriteria(clazz).addOrder(Property.forName("schoolYearNo").desc()).list();
			}
		});
	}

}
